package com.yc.navy.goods.service.lmpl;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.goods.bean.AdminInfo;
import com.yc.navy.goods.dto.AdminInfoDTO;
import com.yc.navy.goods.enums.ResultEnum;
import com.yc.navy.goods.mapper.IAdminInfoMapper;
import com.yc.navy.goods.service.IAdminInfoService;
import com.yc.navy.goods.util.FindByPageParamUtil;
import com.yc.navy.goods.util.StringUtil;
import com.yc.navy.goods.vo.StreamVO;

@Service
public class AdminInfoServiceImpl implements IAdminInfoService {
	@Autowired
	private IAdminInfoMapper adminInfoMapper;
	
	@Override
	public AdminInfoDTO login(AdminInfoDTO af) {
		if(StringUtil.checkNull(af.getAname(), af.getPwd())) {
			return null;
		}
		return adminInfoMapper.login(af);
	}

	@Override
	public int addNumber(int ano) {
		if(StringUtil.checkNull(ano)) {
			return -1;
		}
		return adminInfoMapper.addNumber(ano);
	}

	@Override
	public List<AdminInfo> list() {
		return adminInfoMapper.list();
	}

	@Override
	public StreamVO findByPageForBack(Map<String, Object> map) {
		List<AdminInfo> list = adminInfoMapper.findByPage(FindByPageParamUtil.StreamVOfindByPageParam(map));
		if(list.isEmpty() || list.size() <= 0) {
			return new StreamVO(ResultEnum.ERROR);
		}
		return new StreamVO(list,adminInfoMapper.total());
	}
}
